package com.lanhe.notice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanhe.notice.domain.LhNoticeContent;
import com.lanhe.notice.mapper.LhNoticeContentMapper;
import com.lanhe.notice.service.ILhNoticeContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 公告内容表(LhNoticeContent)表服务实现类
 *
 * @author zhanggl
 * @since 2023-12-30 14:00:35
 */
@Service
public class LhNoticeContentServiceImpl extends ServiceImpl<LhNoticeContentMapper, LhNoticeContent> implements ILhNoticeContentService {

    @Autowired
    private LhNoticeContentMapper noticeContentMapper;

    @Override
    public LhNoticeContent selectNoticeContentByNoticeId(Long noticeId) {
        LambdaQueryWrapper<LhNoticeContent> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(LhNoticeContent::getNoticeContentId, noticeId);
        return noticeContentMapper.selectOne(wrapper);
    }

    @Override
    public Integer insertNoticeContent(Long noticeId, String content) {
        LhNoticeContent noticeContent = new LhNoticeContent();
        noticeContent.setNoticeContentId(noticeId);
        noticeContent.setContent(content);
        return noticeContentMapper.insert(noticeContent);

    }

    @Override
    public Integer updateNoticeContent(Long noticeId, String content) {
        LambdaUpdateWrapper<LhNoticeContent> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(LhNoticeContent::getNoticeContentId, noticeId);
        LhNoticeContent noticeContent = new LhNoticeContent();
        noticeContent.setContent(content);
        return noticeContentMapper.update(noticeContent, wrapper);

    }
}

